﻿using com.guojin.core.io.message;
using com.guojin.mj.net.message.login;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ServicePage : EventManager
{
    private static ServicePage instance;
    public static ServicePage GetInstance()
    {
        return instance;
    }
    void Awake()
    {
        instance = this;
    }

    public Text serviceWXNumber;
    public Button copyBtn;
    public Button Closebtn;

    public override void InformationSetting()
    {
        AddListenerToButton(Closebtn, CloseBtnClick);
        AddListenerToButton(copyBtn, CopyBtnClick);
        #region

        //if (GameData.GetInstance().publicNotic != null && GameData.GetInstance(). publicNotic != "" )
        //{
        //    serviceWXNumber.content = GameData.GetInstance().publicNotic;
        //}
        //else
        //{
        //}

        #endregion
    }

    public void OnReceiveMsg730(string msg, Message data)
    {
        if (GameObject.Find("ServicePage(Clone)"))
        {
            ServiceWXRet swr = (ServiceWXRet)data;
            Debug.Log(swr.serviceWX);
            serviceWXNumber.text = string.Format("游戏客服微信号：{0}", swr.serviceWX);
        }
        else
        {
            Debug.Log("7.30消息找不到ServicePage！");
        }
    }

    void CopyBtnClick()
    {
        if (string.IsNullOrEmpty(serviceWXNumber.text))
        {
            Debug.Log("游戏客服微信号Text为空");
        }
        else
        {
            string str = serviceWXNumber.text.Substring(8);
            LoginAndShare.Controller.CopyTextToClipboard(str);
        }   
    }
}
